<div class="storeProducts form">
<?php echo $this->Form->create('StoreProductMatch',array('url'=>array('plugin'=>'store','controller'=>'products','action'=>'add_match')));?>
	<?php echo $this->Form->hidden('product_id')?>
	<h2><?php __d('store','Add Matching Jewellery');?></h2>				
	<table class="index" cellpadding="0" cellspacing="0">
	<tr>
			<th>&nbsp;</th>
			<th><?php __d('store','Offer Type');?></th>
			<th><?php __d('store','Category');?></th>
			<th><?php __d('store','Name');?></th>
			<th><?php __d('store','Price');?></th>
			<th class="actions"><?php __d('store','Match');?></th>
			<th class="actions"><?php __d('store','Sets');?></th>
	</tr>
	<?php
	$i = 0;
	foreach ($storeProducts as $storeProduct):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
		<td valign="middle" align="left">
			<?php echo $this->Html->link($fileUpload->image($storeProduct['StoreUpload']['name'],array('autoResize'=>true,'width'=>100,'imagePathOnly'=>false))
				, array('action' => 'view', $storeProduct['StoreProduct']['id']),array('escape'=>false)); ?>&nbsp;
		</td>
		<td valign="top" align="left">
			<?php echo (isset($storeProduct['StoreModel']['name'])) ? $storeProduct['StoreModel']['name'] :''; ?>&nbsp;
		</td>
		<td align="left" valign="top">
			<?php 
				if(is_array($storeProduct['StoreCategory']) && !empty($storeProduct['StoreCategory'])){
					foreach ($storeProduct['StoreCategory'] as $cat_key => $category) {
						echo $category['name'].'<br/>';
					}
				}
			?>
		&nbsp;</td>							
		<td valign="top" align="left">
			<?php echo __d('store','Serial Number: ',true).$storeProduct['StoreProduct']['serial_number']; ?>
			<br/>
			<?php echo $storeProduct['StoreProduct']['name']; ?>&nbsp;
		</td>
		<td valign="middle" align="right">
			<?php if($storeProduct['StoreProduct']['price_przecena'] > 0 && $storeProduct['StoreProduct']['price_promocja'] == 0){?>
					<span class="product-view-price-discount"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_detaliczna'],2,'','',$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange'] );?></span> 
					<span class="product-view-price"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_przecena'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange'])?></span> 							 
			<?php }else if( $storeProduct['StoreProduct']['price_promocja'] > 0){?>
					<span class="product-view-price-discount"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_detaliczna'],2,'','',$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange']);?></span> 
					<span class="product-view-price"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_promocja'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange'])?></span> 							
			<?php }else{?>
					<span class="product-view-price"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_detaliczna'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange'])?></span>
			<?php }?>					
		</td>
		<td valign="middle" align="center">
			<?php echo $this->Form->checkbox("match_product_id.{$storeProduct['StoreProduct']['id']}",array('hiddenField'=>false))?> 
		</td>
		<td  class="actions" valign="middle" align="center">								
			<?php echo $this->Form->checkbox("sets.{$storeProduct['StoreProduct']['id']}",array('hiddenField'=>false))?>
		</td>
	</tr>
<?php endforeach; ?>
		<tr>
			<td colspan="7" align="right">
				<?php echo $this->Form->submit(__('Submit',true));?>
			</td>
		</tr>
	</table>
<?php echo $this->Form->end();?>
</div>

<?php if($session->check('Auth.User.id')){?>
<?php echo $this->element('toolbar_actions_main',array('plugin'=>'store','toolbar'=>'product'))?>
<?php }?>